package cn.car.domains.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 排放标准
 */
@Getter
@AllArgsConstructor
public enum EmissionStandardEnum {
    UNDEFINED(Integer.MIN_VALUE, "常规管控"),
    CN_0(0, "0","国零"),
    CN_1(1, "1","国一"),
    CN_2(2, "2","国二"),
    CN_3(3, "3","国三"),
    CN_4(4, "4","国四"),
    CN_5(5, "5","国五"),
    CN_6(6, "6","国六"),
    ELECTRIC(7, "D","电动"),
    ;
    private final int index;
    private final String govCode;
    private final String desc;

    EmissionStandardEnum(int index, String govCode) {
        this.index = index;
        this.govCode = govCode;
        this.desc = govCode;
    }

    public static EmissionStandardEnum indexOf(Integer index) {
        if (index == null) {
            return null;
        }
        for (EmissionStandardEnum color : values()) {
            if (color.index == index) {
                return color;
            }
        }
        return null;
    }

    public static EmissionStandardEnum govCodeOf(String govCode) {
        if (govCode == null) {
            return null;
        }
        for (EmissionStandardEnum color : values()) {
            if (color.govCode.equals(govCode)) {
                return color;
            }
        }
        return null;
    }
}
